import java.util.*;

class Stu implements Comparable<Stu>{
    public String name;
    public int age;

    public Stu(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public int compareTo(Stu o) {
        return this.age-o.age;
    }

    @Override
    public String toString() {
        return "Stu{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
public class Test {
    public static void main(String[] args) {
       /* List<String> name =new ArrayList<>();
        Collections.addAll(name,"张三","李四","王五");
        System.out.println(name);
        Collections.shuffle(name);
        System.out.println(name);
        List<Integer> list=new ArrayList<>();
        list.add(2);
        list.add(5);
        list.add(1);
        list.add(4);
        Collections.sort(list);
        System.out.println(list);*/
        List<Stu> stu=new ArrayList<>();
        stu.add(new Stu("张三",9));
       stu.add( new Stu("李四",10));
       stu.add( new Stu("王五",8));
        Collections.sort(stu);
        System.out.println(stu);

    }

}
